import BackLayout from "@/layout/back/BackLayout.vue";
import FrontLayout from "@/layout/front/FrontLayout.vue";
import { RouteRecordRaw } from "vue-router";
import ParentLayout from "@/layout/ParentLayout.vue";
import NoticeManage from "@/views/back/system/notice/NoticeManage.vue";
import AdminManage from "@/views/back/system/admin/AdminManage.vue";
import LoginPage from "@/views/basic/LoginPage.vue";
import { UserTypeEnum } from "@/types/UserTypeEnum";
import NotPermissionPage from "@/views/basic/NotPermissionPage.vue";
import NotFoundPage from "@/views/basic/NotFoundPage.vue";
import RegisterPage from "@/views/basic/RegisterPage.vue";
import LoginLogManage from "@/views/back/system/loginLog/LoginLogManage.vue";
import OperationLogManage from "@/views/back/system/operationLog/OperationLogManage.vue";
import BusinessManage from "@/views/back/system/business/BusinessManage.vue";
import ImChat from "@/components/chat/ImChat.vue";
import GoodsTypeManage from "@/views/back/system/goodsType/GoodsTypeManage.vue";
import GoodsManage from "@/views/back/system/goods/GoodsManage.vue";
import GoodsSkuManage from "@/views/back/system/goods/components/GoodsSkuManage.vue";
import HomeView from "@/views/front/HomeView.vue";
import InfoView from "@/views/front/InfoView.vue";
import TypeView from "@/views/front/TypeView.vue";
import GoodsDetail from "@/views/front/GoodsDetail.vue";
import BannerManage from "@/views/back/system/banner/BannerManage.vue";
import SearchView from "@/views/front/SearchView.vue";
import CartView from "@/views/front/CartView.vue";
import HistoryCollectView from "@/views/front/HistoryCollectView.vue";
import TestHome from "@/views/TestHome.vue";
import BackInfoView from "@/views/back/system/BackInfoView.vue";
import OrdersPayView from "@/views/front/OrdersPayView.vue";
import PayFormView from "@/components/PayFormView.vue";
import OrdersView from "@/views/front/OrdersView.vue";
import OrdersManage from "@/views/back/system/orders/OrdersManage.vue";
import BackHomeView from "@/views/back/BackHomeView.vue";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/backend",
    name: "backend",
    component: BackLayout,
    redirect: "/backend/home",
    meta: { title: "后台", minRole: UserTypeEnum.BUSINESS },
    children: [
      {
        path: "home",
        name: "backend-home",
        meta: {
          title: "首页",
          icon: "icon-shouye",
          minRole: UserTypeEnum.BUSINESS,
        },
        component: BackHomeView,
      },
      {
        path: "system",
        name: "system",
        meta: {
          title: "系统管理",
          icon: "icon-xitong",
          minRole: UserTypeEnum.BUSINESS,
        },
        component: ParentLayout,
        children: [
          {
            path: "notice",
            name: "b-notice",
            meta: {
              title: "公告管理",
              icon: "icon-gonggao",
              minRole: UserTypeEnum.BUSINESS,
            },
            component: NoticeManage,
          },
          {
            path: "admin",
            name: "b-admin",
            meta: {
              title: "管理员管理",
              icon: "icon-guanliyuan",
              minRole: UserTypeEnum.SUPER_ADMIN,
            },
            component: AdminManage,
          },
          {
            path: "business",
            name: "b-business",
            meta: {
              title: "商家管理",
              icon: "icon-business",
              minRole: UserTypeEnum.ADMIN,
            },
            component: BusinessManage,
          },
        ],
      },
      {
        path: "log",
        name: "log",
        meta: {
          title: "日志管理",
          icon: "icon-rizhi",
          minRole: UserTypeEnum.ADMIN,
        },
        component: ParentLayout,
        redirect: "/log/loginLog",
        children: [
          {
            path: "loginLog",
            name: "b-login-log",
            meta: {
              title: "登录日志",
              icon: "icon-login-log",
              minRole: UserTypeEnum.ADMIN,
            },
            component: LoginLogManage,
          },
          {
            path: "operationLog",
            name: "b-operation-log",
            meta: {
              title: "操作日志",
              icon: "icon-cz-rizhi",
              minRole: UserTypeEnum.ADMIN,
            },
            component: OperationLogManage,
          },
        ],
      },
      {
        path: "goods",
        name: "b-goods",
        meta: {
          title: "商品管理",
          icon: "icon-shangpin",
          minRole: UserTypeEnum.BUSINESS,
        },
        component: ParentLayout,
        children: [
          {
            path: "goodsType",
            name: "b-goodsType",
            meta: {
              title: "商品分类",
              icon: "icon-fenlei",
              minRole: UserTypeEnum.ADMIN,
            },
            component: GoodsTypeManage,
          },
          {
            path: "goods_info",
            name: "b-goods-info",
            meta: {
              title: "商品信息管理",
              icon: "icon-shangpin",
              minRole: UserTypeEnum.BUSINESS,
            },
            component: GoodsManage,
          },
          {
            path: "goods_sku/:goodsId",
            name: "b-goods-sku",
            meta: {
              noShow: true,
              title: "商品Sku管理",
              icon: "icon-shangpin",
              minRole: UserTypeEnum.BUSINESS,
            },
            component: GoodsSkuManage,
          },
          {
            path: "goods_banner",
            name: "b-goods-banner",
            meta: {
              title: "轮播图管理",
              icon: "icon-shangpin",
              minRole: UserTypeEnum.ADMIN,
            },
            component: BannerManage,
          },
          {
            path: "orders",
            name: "b-orders",
            meta: {
              title: "订单管理",
              icon: "icon-dingdan",
              minRole: UserTypeEnum.BUSINESS,
            },
            component: OrdersManage,
          },
        ],
      },
      {
        path: "basic",
        name: "b-basic",
        meta: {
          title: "基本管理",
          noShow: true,
          minRole: UserTypeEnum.BUSINESS,
        },
        component: ParentLayout,
        children: [
          {
            path: "info",
            name: "b-info",
            meta: {
              title: "个人信息",
              minRole: UserTypeEnum.BUSINESS,
            },
            component: BackInfoView,
          },
        ],
      },
      {
        path: "chat",
        name: "b-chat",
        meta: {
          title: "聊天窗口",
          minRole: UserTypeEnum.BUSINESS,
          noShow: true,
        },
        component: ImChat,
      },
    ],
  },
  {
    path: "/",
    name: "front",
    component: FrontLayout,
    redirect: "/home",
    meta: { title: "前台" },
    children: [
      {
        path: "home",
        name: "f-home",
        meta: { title: "首页" },
        component: HomeView,
      },

      {
        path: "info",
        name: "f-info",
        meta: { title: "个人页面" },
        component: InfoView,
      },

      {
        path: "type",
        name: "f-type",
        meta: { title: "商品分类" },
        component: TypeView,
      },
      {
        path: "goods_detail/:goodsId",
        name: "f-goods-detail",
        meta: { title: "商品详情" },
        component: GoodsDetail,
      },
      {
        path: "chat",
        name: "f-chat",
        meta: {
          title: "聊天窗口",
          minRole: UserTypeEnum.USER,
        },
        component: ImChat,
      },
      {
        path: "search",
        name: "f-search",
        meta: {
          title: "搜索结果",
        },
        component: SearchView,
      },
      {
        path: "cart",
        name: "f-cart",
        meta: {
          title: "购物车",
          minRole: UserTypeEnum.USER,
        },
        component: CartView,
      },
      {
        path: "orders",
        name: "f-orders",
        meta: {
          title: "订单",
          minRole: UserTypeEnum.USER,
        },
        component: OrdersView,
      },
      {
        path: "history_collect",
        name: "f-history_collect",
        meta: {
          title: "历史与收藏",
          minRole: UserTypeEnum.USER,
        },
        component: HistoryCollectView,
      },
      {
        path: "orders_pay/:payNo",
        name: "f-orders_pay",
        meta: {
          title: "订单结算",
          minRole: UserTypeEnum.USER,
        },
        component: OrdersPayView,
      },
      {
        path: "pay_form",
        name: "f-pay_form",
        meta: {
          title: "支付页",
          minRole: UserTypeEnum.USER,
        },
        component: PayFormView,
      },
    ],
  },
  {
    path: "/basic",
    name: "basic",
    component: ParentLayout,
    children: [
      {
        path: "login",
        name: "login",
        meta: { title: "登录" },
        component: LoginPage,
      },
      {
        path: "register",
        name: "register",
        meta: { title: "注册" },
        component: RegisterPage,
      },
      {
        path: "403",
        name: "403",
        meta: { title: "无权限" },
        component: NotPermissionPage,
      },
      {
        path: "im-chat",
        name: "imChat",
        meta: { title: "聊天" },
        component: ImChat,
      },

      {
        path: "test_home",
        name: "test_home",
        meta: { title: "测试首页" },
        component: TestHome,
      },
    ],
  },
  {
    path: "/:pathMatch(.*)",
    name: "404",
    meta: { title: "无法访问" },
    component: NotFoundPage,
  },
];

export default routes;
